
const express = require('express');
const app = express();

const middlewares = [(req, res, next) => {
    console.log('00');
    next()
}, (req, res, next) => {
    console.log('11');
    next()
}, (req, res, next) => {
    console.log('22');
    next()
}]


app.use('/', middlewares);


app.use('/ajax', (req, res) => {
    res.send('~~ajax')
});

app.use('/api', (req, res) => {
    res.send('~~api')
});



// 回调函数称为中间件
// 中间件 栈

// app.use('/', (req, res, next) => {
//     console.log('00');
//     next()
// }, (req, res, next) => {
//     console.log('11');
//     next()
// }, (req, res, next) => {
//     console.log('22');
//     next()
// });



app.listen(8080, (err) => {
    console.log('监听8080');
})